// 导入封装请求的js文件
import request from "@/utils/request";

export const getInfoAPI = () => {
  return request({
    url: "/comments",
    method: "get",
  });
};

// export const getLoginAPI = () => {
//     return request({
//         url: '/account',
//         method: 'get'
//     })
// }
// 获取首页信息 API
export const getHomeMsgAPI = () => {
  return request({
    url: "/lib/home",
    method: "GET",
  });
};

// 获取导航菜单 API
export const getMenusAPI = () => {
  return request({
    url: "/lib/menus",
    method: "GET",
  });
};

// 登录 API
export const getLoginAPI = ({ username, password, role }) => {
  return request({
    url: "/api/login",
    method: "post",
    data: {
      username,
      password,
      role,
    },
  });
};
// ------------superuser--------------------
// 获取管理员列表
export const getSupUserListAPI = (pagenum, pagesize) => {
  return request({
    url: "/lib/admin",
    method: "GET",
    params: {
      pagenum,
      pagesize,
    },
  });
};
// 更新管理员信息
export const uptSupUserAPI = ({ id, username, password, status, role }) => {
  return request({
    url: "/lib/admin",
    method: "PUT",
    data: {
      id,
      username,
      password,
      status,
      role,
    },
  });
};
// 删除管理员
export const delSupUserAPI = (id) => {
  return request({
    url: "/lib/admin",
    method: "delete",
    params: {
      id,
    },
  });
};
// 新增管理员
export const addSupUserAPI = ({ username, password, status, role }) => {
  return request({
    url: "/lib/admin",
    method: "POST",
    data: {
      username,
      password,
      status,
      role,
    },
  });
};
// ------------user--------------------
// 获取用户列表
export const getUserListAPI = (pagenum, pagesize) => {
  return request({
    url: "/lib/user",
    method: "GET",
    params: {
      pagenum,
      pagesize,
    },
  });
};
// 添加用户
export const addUserAPI = (obj) => {
  console.log(obj);
  return request({
    url: "/lib/user",
    method: "POST",
    data: obj,
  });
};
// 编辑用户
export const uptUserAPI = (obj) => {
  return request({
    url: "/lib/user",
    method: "PUT",
    data: obj,
  });
};
// 删除读者
export const delUserAPI = (id) => {
  return request({
    url: "/lib/user",
    method: "delete",
    params: {
      id,
    },
  });
};
// ------------分类------------------
export const getClassifyListAPI = (pagenum, pagesize) => {
  return request({
    url: "/lib/classify",
    method: "GET",
    params: {
      pagenum,
      pagesize,
    },
  });
};
export const addClassifyAPI = (obj) => {
  return request({
    url: "/lib/classify",
    method: "POST",
    data: obj,
  });
};
export const uptClassifyAPI = (obj) => {
  return request({
    url: "/lib/classify",
    method: "put",
    data: obj,
  });
};
export const delClassifyAPI = (id) => {
  return request({
    url: "/lib/classify",
    method: "delete",
    params: {
      id,
    },
  });
};
// ------------书架------------------
export const getShelfListAPI = (pagenum, pagesize) => {
  return request({
    url: "/lib/shelf",
    method: "GET",
    params: {
      pagenum,
      pagesize,
    },
  });
};
export const addShelfAPI = (obj) => {
  return request({
    url: "/lib/Shelf",
    method: "POST",
    data: obj,
  });
};
export const uptShelfAPI = (obj) => {
  return request({
    url: "/lib/Shelf",
    method: "put",
    data: obj,
  });
};
export const delShelfAPI = (id) => {
  return request({
    url: "/lib/Shelf",
    method: "delete",
    params: {
      id,
    },
  });
};
// ------------图书------------------
export const getBookListAPI = (pagenum, pagesize) => {
  return request({
    url: "/lib/list",
    method: "GET",
    params: {
      pagenum,
      pagesize,
    },
  });
};
export const addBookAPI = (obj) => {
  return request({
    url: "/lib/list",
    method: "post",
    data: obj,
  });
};
export const uptBookAPI = (obj) => {
  return request({
    url: "/lib/list",
    method: "put",
    data: obj,
  });
};
export const delBookAPI = (id) => {
  return request({
    url: "/lib/list",
    method: "delete",
    params: {
      id,
    },
  });
};
// ------------借阅------------------
export const getBorrowListAPI = (pagenum, pagesize) => {
  return request({
    url: "/lib/borrow",
    method: "GET",
    params: {
      pagenum,
      pagesize,
    },
  });
};
export const addBorrowAPI = (obj) => {
  return request({
    url: "/lib/borrow",
    method: "post",
    data: obj,
  });
};
export const uptBorrowAPI = (obj) => {
  return request({
    url: "/lib/borrow",
    method: "put",
    data: obj,
  });
};
export const delBorrowAPI = (id) => {
  return request({
    url: "/lib/borrow",
    method: "delete",
    params: {
      id,
    },
  });
};
